package com.ycd.Servlet;

import com.ycd.Entity.LanMuEntity;
import com.ycd.Entity.UserEntity;
import com.ycd.Entity.XinWenEntity;
import com.ycd.Service.LanMuEntityService;
import com.ycd.Service.XinWenEntityService;
import com.ycd.Service.impl.LanMuEntityServiceImpl;
import com.ycd.Service.impl.XinWenEntityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description 首页展示
 * @Author ycd
 * @Date : 2022/3/16 17:12
 * @Version : 1.0
 */
@WebServlet("/NewsManagement.html")
public class ShowNewsHtmlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        XinWenEntityService xinWenEntityService=new XinWenEntityServiceImpl();
        List<XinWenEntity> xinWenEntities = xinWenEntityService.queryAll();
        req.setAttribute("xinWenEntities",xinWenEntities);

        req.getRequestDispatcher("/WEB-INF/page/NewsManagement.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}